package study2019.daily;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

public class August {
	// @Test
	// public void test1() {
	// Integer int1 = 1;
	// Integer int2 = 1;
	// Integer int3 = 123;
	// Integer int4 = 12345;
	// System.out.println(int1 == int2);
	// System.out.println(int1 == int4);
	// System.out.println(int2 == int3);
	//
	// }

	@Test
	/**
	 * 统计任务
	 */
	public void test2() {
		Set<String> set = new HashSet<>();
		set.add("td_b_ptype_product");
		set.add("td_b_product");
		set.add("td_b_package");
		set.add("td_b_package_element");
		set.add("td_b_discnt");
		set.add("td_b_discnt_item");
		set.add("td_b_product_item");
		set.add("td_b_product_package");
		set.add("td_b_product_tradefee");
		set.add("td_b_service");
		set.add("td_b_service_item");
		set.add("td_s_productlimit");
		set.add("td_s_prod_spec_limit");
		set.add("td_s_product_type");
		set.add("td_s_prod_res_rel");
		set.add("td_b_product_release");
		set.add("TD_M_DATARIGHT".toLowerCase());
		set.add("TF_M_OBJECTDATARIGHT".toLowerCase());
		set.add("TF_M_ROLEDATARIGHT_NEW".toLowerCase());
		for (int i = 1; i <= 8; i++) {
			Set<String> set2 = readFileByLines(
					"C:\\Users\\18502\\Desktop\\新建文件夹\\ue" + i + "\\crm" + i + "tops_table_out_map.out");
			for (String str : set) {
				if (!set2.contains(str.toLowerCase().trim())) {
					// System.out.println(i + "不包含" + str.toLowerCase().trim());
				} 
				else {
					System.out.println(i + "包含" + str.toLowerCase().trim());
				}
			}
		}


	}

	/** 
	 * 以行为单位读取文件，常用于读面向行的格式化文件 
	 */
	public static Set<String> readFileByLines(String fileName) {
		Set<String> set = new HashSet<>();
		File file = new File(fileName);
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			String tempString = null;
			int line = 1;
			// 一次读入一行，直到读入null为文件结束
			while ((tempString = reader.readLine()) != null) {
				// 显示行号
				if (tempString.indexOf("TABLE") >= 0) {
					set.add(tempString.substring(tempString.indexOf(".") + 1).replace(";", "").toLowerCase().trim());
				}
				line++;
			}
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e1) {
				}
			}
		}
		return set;
	}

}
